import { createRouter, createWebHistory } from 'vue-router'
import Login from '@/views/login/index.vue'
import Privacy from '@/views/login/privacy.vue'
import vip from '@/views/vip/index.vue'
import billDetails from '@/views/vip/billDetails.vue'
import chooseRights from '@/views/vip/chooseRights.vue'
import equity from '@/views/vip/equity.vue'
import My from '@/views/my/index.vue'
import UserCenter from '@/views/my/userCenter.vue'
import NickName from '@/views/my/nickname.vue'
import Profile from '@/views/my/profile.vue'
import friends from '@/views/my/friends.vue'
import address from '@/views/my/address.vue'
import needs from '@/views/my/needs.vue'
import needsAdd from '@/views/my/needsAdd.vue'
import needsDetail from '@/views/my/needsDetail.vue'
import healthList from '@/views/health/index.vue'

const routes = [{
        path: '',
        redirect: '/vip',
    },
    { path: '/login', component: Login },
    { path: '/privacy', component: Privacy },
    { path: '/vip', component: vip },
    { path: '/equity', component: equity },
    { path: '/billDetails', component: billDetails },
    { path: '/my', component: My },
    { path: '/userCenter', component: UserCenter },
    { path: '/nickName', component: NickName },
    { path: '/profile', component: Profile },
    { path: '/friends', component: friends },
    { path: '/address', component: address },
    { path: '/needs', component: needs },
    { path: '/needsAdd', component: needsAdd },
    { path: '/needsDetail', component: needsDetail },
    { path: '/chooseRights', component: chooseRights },
    { path: '/health', component: healthList },
]

const router = createRouter({
    history: createWebHistory(),
    routes
})

export const navigateTo = (path = '/home', query = {}) => {
    router.push({ path, query })
}

export const navigateBack = (num = -1) => {
    router.go(num)
}

export const replaceTo = (path = '/home', query = {}) => {
    router.replace({ path, query })
}


export default router